/*
 *   Copyright 2020-2021 Rosemoe
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package io.github.rosemoe.editor.text;

/**
 * This is the listener for content.
 * You will receive calls when the Content object is going to change or changed.
 *
 * @author Rose
 */
public interface ContentListener {

    /**
     * This is to notify you that you will receive {@link ContentListener#afterDelete(Content, int, int, int, int, CharSequence)}
     * and {@link ContentListener#afterInsert(Content, int, int, int, int, CharSequence)} calls.
     * These two calls are a action of replacement.
     * <strong> You are not expected to make changes to this Content object at this method. </strong>
     *
     * @param content The target Content object being replaced text
     */
    void beforeReplace(Content content);

    /**
     * This is to notify you that the given Content object has inserted text with the given position and text
     *
     * @param content         The Content which has inserted the given text
     * @param startLine       The insertion position line
     * @param startColumn     The insertion position column on line
     * @param endLine         The line position of the last character in inserted content
     * @param endColumn       The column position after the last character in inserted content
     * @param insertedContent The content inserted
     */
    void afterInsert(Content content, int startLine, int startColumn, int endLine, int endColumn, CharSequence insertedContent);

    /**
     * This is to notify you that the Content object has deleted the text with the given position.
     *
     * @param content        The Content which has deleted text
     * @param startLine      The start line of deleted text
     * @param startColumn    The start column of deleted text
     * @param endLine        The end line of deleted text
     * @param endColumn      The end column of deleted text(But this character not deleted)
     * @param deletedContent The text deleted.Generated by Content object.
     */
    void afterDelete(Content content, int startLine, int startColumn, int endLine, int endColumn, CharSequence deletedContent);

}
